#!/bin/bash -ex

LOCAL_IDLIZE_PATH="${1:-"/home/aleks/repos/idlize"}"

# ARK_AOT="${LOCAL_IDLIZE_PATH}/external/arkoala-arkts/node_modules/@koalaui/panda/node_modules/@panda/sdk/linux_host_tools/bin/ark_aot"
# ARK_AOT="/home/aleks/build_dirs/panda_sdks_buids/sdk_host_release/linux_host_tools/bin/ark_aot"
# ARK_AOT="/home/aleks/build_dirs/panda_sdks_buids/sdk_host_fastverify/linux_host_tools/bin/ark_aot"
# ARK_AOT="/home/aleks/build_dirs/panda_sdks_buids/sdk_host_relwithdebinfo/linux_host_tools/bin/ark_aot"

ARK_AOT="${LOCAL_IDLIZE_PATH}/external/incremental/tools/panda/node_modules/@panda/sdk/linux_host_tools/bin/ark_aot"

ETS_STDLIB_DIR="${LOCAL_IDLIZE_PATH}/external/incremental/tools/panda/node_modules/@panda/sdk/ets"
ETS_STDLIB_PATH="${ETS_STDLIB_DIR}/etsstdlib.abc"

ARKOALA_DIR="${LOCAL_IDLIZE_PATH}/external/arkoala-arkts/build/bootPandaFiles"
ARKOALA_PATH="${ARKOALA_DIR}/arkoala.abc"

USER_DIR="${LOCAL_IDLIZE_PATH}/external/arkoala-arkts/build/userPandaFiles"
USER_PATH="${USER_DIR}/user.abc"

ADDITIONAL_ARGS="--load-runtimes=ets --log-level=debug --log-components=AOT" # --log-level=debug --log-components=AOT:events:compiler" #--compiler-max-vregs-num=24564

${ARK_AOT} ${ADDITIONAL_ARGS} --boot-panda-files="${ETS_STDLIB_PATH}" --paoc-panda-files="${ETS_STDLIB_DIR}/etsstdlib.abc" --paoc-output="${ETS_STDLIB_DIR}/etsstdlib.an"

${ARK_AOT} ${ADDITIONAL_ARGS} --boot-panda-files="${ETS_STDLIB_PATH}:${ARKOALA_PATH}" --paoc-panda-files="${ARKOALA_DIR}/arkoala.abc" --paoc-output="${ARKOALA_DIR}/arkoala.an"

${ARK_AOT} ${ADDITIONAL_ARGS} --boot-panda-files="${ETS_STDLIB_PATH}:${ARKOALA_PATH}:${USER_PATH}" --paoc-panda-files="${USER_DIR}/user.abc" --paoc-output="${USER_DIR}/user.an"

echo "WIN_WIN"
